package com.example.config;
import org.springframework.format.support.FormattingConversionService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Arrays;

@Configuration
public class WebConfig {

    @Value("${file.upload-dir}")
    private String uploadDir;

    /*
     * SpringBoot配置Servlet
     * */
    @Bean
    public ServletRegistrationBean<FileServlet> registrationServlet(){
//        System.out.println("servlet   gfdsgdsgasdgsdagsdagsdags\n");
        ServletRegistrationBean<FileServlet> servletRegistrationBean = new ServletRegistrationBean<>(new FileServlet(uploadDir));
        servletRegistrationBean.setUrlMappings(Arrays.asList("/files/*"));
        return servletRegistrationBean;
    }

}
